package com.purong.purong.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.purong.purong.R;
import com.purong.purong.adapter.LoanHouseAdapter;
import com.purong.purong.adapter.ViewPagerAdapter;
import com.purong.purong.fragment.HouseRateFragment;

import java.util.ArrayList;

/**
 * Created by zengwenjie on 2017/12/4.
 */
public class HouseRateActivity extends BaseActivity {
    private SlidingTabLayout tabLayout;
    private ViewPager mViewPager;
    private ViewPagerAdapter mAdapter;
    private ArrayList<Fragment> fragmentList = new ArrayList<>();
    private ArrayList<String> titleList = new ArrayList<>();
    @Override
    public int getRootViewId() {
        return R.layout.activity_house_rate;
    }

    @Override
    public void initView() {
        tabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tablayout);
        mViewPager = (ViewPager) findViewById(R.id.view_pager);
        Bundle bundle;
        HouseRateFragment houseOneFragment;
        houseOneFragment=new HouseRateFragment();
        bundle=new Bundle();
        bundle.putInt("TYPE", LoanHouseAdapter.TYPE_ONE);
        houseOneFragment.setArguments(bundle);
        fragmentList.add(houseOneFragment);
        houseOneFragment=new HouseRateFragment();
        bundle=new Bundle();
        bundle.putInt("TYPE", LoanHouseAdapter.TYPE_TWO);
        houseOneFragment.setArguments(bundle);
        fragmentList.add(houseOneFragment);
        houseOneFragment=new HouseRateFragment();
        bundle=new Bundle();
        bundle.putInt("TYPE", LoanHouseAdapter.TYPE_THREE);
        houseOneFragment.setArguments(bundle);
        fragmentList.add(houseOneFragment);
        titleList.add("首套房");
        titleList.add("二套房");
        titleList.add("商用房");
        mAdapter = new ViewPagerAdapter(getSupportFragmentManager(), fragmentList);
        mAdapter.setPageTitle(titleList);
        mViewPager.setAdapter(mAdapter);
        mViewPager.setOffscreenPageLimit(1);

        tabLayout.setViewPager(mViewPager);
        tabLayout.setTabSpaceEqual(true);
        tabLayout.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {

            }

            @Override
            public void onTabReselect(int position) {


            }
        });
    }

    @Override
    public void initData() {

    }
    public void onClick(View v){
        switch (v.getId()){
            case R.id.left_back:
                finish();
                break;
        }
    }
}
